This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter. # Cellchat
source("./tianfengRwrappers.R")
library(CellChat)
ds2 <- readRDS("ds2.rds")
CA_dataset2 <- readRDS("CA_dataset2.rds")
# saveRDS(CA_dataset2,"CA_dataset2.rds")
umapplot(CA_dataset2)
Warning: Using `as.character()` on a quosure is deprecated as of rlang 0.3.0.
Please use `as_label()` or `as_name()` instead.
This warning is displayed once per session.
f("DLX5",EC_SMC)
umapplot(EC_SMC)
saveRDS(EC_SMC,"EC_SMC.rds")
computeAveExpr(cor, features = c("BMP2","BMP4","BMP6","BMPR1B","BMPR1A","BMPR2","ACVR2A"), type = "truncatedMean", trim = 0.05)
3 EC0 EC1 EC2 Fibroblast Fibromyocyte Pericyte SMC1 SMC2
BMP2 0.03150669 0.02623810 0.003702709 0.202131802 0.00000000 0.00000000 0.028212306 0.000000000 0.00000000
BMP4 0.00000000 0.02969807 0.064427142 0.535072542 0.14289603 0.05976591 0.000000000 0.008078115 0.02235959
BMP6 0.33885091 0.00000000 0.000000000 0.430656995 0.00000000 0.00000000 0.000000000 0.000000000 0.00000000
BMPR1B 0.00000000 0.00000000 0.000000000 0.000000000 0.08194540 0.00000000 0.000000000 0.008751292 0.07602259
BMPR1A 0.00000000 0.00000000 0.000000000 0.006539124 0.05175499 0.03366126 0.009241962 0.057668768 0.02832214
BMPR2 0.30466733 0.28211628 0.328085107 0.880202371 0.11521646 0.13015395 0.078799890 0.157702091 0.11248721
ACVR2A 0.00000000 0.00000000 0.000000000 0.000000000 0.01848392 0.00000000 0.000000000 0.000000000 0.00000000
write.csv(df.net,"./datatable/EC_SMC_cellchat_res.csv", row.names = F)
cor <- readRDS("EC_SMC_cellchat.rds")
# cor@idents <- plyr::revalue(cor@idents, c("Mod_SMC"="Fibroblast", "SMC_0"="SMC1","SMC_1"="Fibromyocyte",
# "SMC_2"="Pericyte","SMC_3"="SMC2"))
table(cor@idents)
groupSize <- as.numeric(table(cor@idents))
netVisual_circle(cor@net$weight, vertex.weight = groupSize, weight.scale = T, label.edge= F, title.name = "Interaction weights/strength")
netVisual_heatmap(cor, measure = "weight", signaling = NULL, color.heatmap = c("#f1f1f1", "#ff2121"))
#一次分析不同细胞亚群
mat <- cor@net$weight
for (i in 1:nrow(mat)) {
mat2 <- matrix(0, nrow = nrow(mat), ncol = ncol(mat), dimnames = dimnames(mat))
mat2[i, ] <- mat[i, ]
netVisual_circle(mat2, vertex.weight = groupSize, weight.scale = T, edge.weight.max = max(mat), title.name = rownames(mat)[i])
}
# pheatmap(mat, display_numbers = FALSE, number_color ="black", cluster_rows = FALSE,
# cluster_cols = FALSE, color = colorRampPalette(c("#1E90FF", "white", "#ff2121"))(400), border_color = NA)
netVisual_aggregate(cor, signaling = pathways.show, layout = "circle")
netVisual_bubble(cor, sources.use = 4, targets.use = c(5:9), pairLR.use = LR_show, remove.isolate = F) #EC2 target
Comparing communications on a single object
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.